using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Web;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using XPStudio.UMS.Model;
using XPStudio.UMS.DAL;

namespace XPStudio.UMS.BLL
{
    public class RoleBLL
    {
        public static DataSet GetRoles()
        {
            return XPStudio.UMS.DAL.RoleDAL.GetRoleList();
        }

        
        public static SqlDataReader GetMembers(int roleid)
        {
            return XPStudio.UMS.DAL.RoleDAL.GetMembers(roleid);
        }

        public static DataSet GetRoleMember(int roleid)
        {
            return DAL.RoleDAL.GetRoleMember(roleid);
        }

        public static ListBox GetMemberList(int roleid)
        {
            return XPStudio.UMS.DAL.RoleDAL.GetMemberList(roleid);
        }

        public static void AddMember(int userid, int roleid)
        {
            XPStudio.UMS.DAL.RoleDAL.AddMember(userid, roleid);
        }
        public static void DelMember(int userid, int roleid)
        {
             XPStudio.UMS.DAL.RoleDAL.DelMember(userid, roleid);
        }

        public static int AddRole(RoleModel role)
        {
            return XPStudio.UMS.DAL.RoleDAL.AddRole(role);
        }

        public static bool DelRole(int roleid)
        {
            return XPStudio.UMS.DAL.RoleDAL.DelRole(roleid);
        }

        public static bool UpdateRole(RoleModel role)
        {
            return XPStudio.UMS.DAL.RoleDAL.UpdateRole(role);
        }

        public static bool SetRolePermit(int roleid, int appid, int moduleid, string allow, string deny)
        {
            return DAL.RoleDAL.SetRolePermit(roleid, appid, moduleid, allow, deny);
        }

        public static RoleModel GetRoleInfo(int roleid)
        {
            return DAL.RoleDAL.GetRoleInfo(roleid);
        }

        public static RoleModel GetRoleWithPermit(int roleid)
        {
            return DAL.RoleDAL.GetRoleWithPermit(roleid);
        }
        public static DataSet GetRolePermit(int roleid, int appid)
        {
            return DAL.RoleDAL.GetRolePermit(roleid, appid);
        }
        public static DataSet GetRolePermit(int roleid, int appid, int moduleid)
        {
            return DAL.RoleDAL.GetRolePermit(roleid, appid, moduleid);
        }

        public static bool HasPermit(int roleid, int appid)
        {
            RoleModel role = new RoleModel();
            if (role.AllowApp.Contains(appid))
                return true;
            else
                return false;
        }

        //public static bool HasPermit(int roleid , int appid , int moduleid)
        //{
        //    RoleModel role = new RoleModel();
        //    if (role.AllowApp.Contains(appid))
        //    {
        //        if 

    }
}
